var _cardUtil = _interopRequireDefault(require("../../utils/card-util")), _contactUtil = require("../../utils/contact-util"), _radarUtil = require("../../utils/radar-util");

function _interopRequireDefault(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

var qrcodeTask = {};

Component({
    properties: {
        card: {
            type: Object,
            value: {},
            observer: function(t) {
                t = t || {}, this.handle(t);
            }
        },
        self: {
            type: Object,
            value: {}
        },
        isPlanView: {
            type: Boolean,
            value: !1
        },
        mode: {
            type: String,
            value: "view"
        },
        skeleton: {
            type: Boolean,
            value: !1
        }
    },
    data: {
        STATUS: _contactUtil.STATUS,
        CLAIM: _contactUtil.CLAIM,
        AUTH: _cardUtil.default.AUTH,
        GRADE: _cardUtil.default.GRADE,
        STYLES: _cardUtil.default.STYLES,
        VERSION: _cardUtil.default.VERSION
    },
    ready: function() {
        this.data.skeleton && this.selectComponent("#skeleton").create(this);
    },
    methods: {
        goEdit: function() {
            this.$route("/pages/card/edit/edit");
        },
        openDebug: function() {
            "index" === this.data.mode && this.$app.openDebug("card_index");
        },
        handle: function(t) {
            t.cardid && (+t.cardstyle === _cardUtil.default.STYLES.BUSINESS && this.getQrcodeUrl(t), 
            this.data.skeleton && this.setData({
                skeleton: !1
            }));
        },
        getQrcodeUrl: function(t) {
            var a = this, e = t.cardid + "" + t.updatetime;
            qrcodeTask[e] || (qrcodeTask[e] = _cardUtil.default.getQrcode(t)), qrcodeTask[e].then(function(t) {
                return a.setData({
                    qrcode: t
                });
            });
        },
        showAvatar: function() {
            var t = this.data.card;
            t.cardid && _cardUtil.default.showAvatar(t);
        },
        showQrcode: function() {
            this.data.card.cardid && _cardUtil.default.showQrcode(this.data.qrcode);
        },
        call: function() {
            var t = this.data, a = t.card, e = t.mode, i = this.$appData.tokens;
            if (a.cardid) {
                if (!i || !i.accesstoken) return this.triggerEvent("fail", {
                    errMsg: "not find user data"
                }, {});
                _cardUtil.default.callCardMobile(this.data.card), "view" === e && (this.radarPush(_radarUtil.RADAR_TYPES.CALL), 
                this.$report("card_view_tap_call"));
            }
        },
        radarPush: function(t, a) {
            (0, _radarUtil.radarPush)(this.data.card, t, a);
        },
        openAuthModal: function() {
            var t = this.data, a = t.card, e = t.isPlanView;
            1 != +a.authstatus || e || this.triggerEvent("openmodal");
        },
        gotoAuthPage: function() {
            var t = this.data, a = t.card;
            t.self.cardid === a.cardid && (a.isCreator || a.isAdmin) && _cardUtil.default.checkCorpAuth(a.guid);
        },
        onWaitJoin: function() {
            _cardUtil.default.waitJoinModal(!0);
        }
    }
});